Written by Jerry Aman, Optima System, July 28, 1996.
Part of the PageSpinner distribution.
We will not be held responsible for any unwanted
effects due to the usage of this script or any derivative.
No warrantees for usability for any specific application
are given or implied.
You are free to use and modify this script,
if all credits are kept in the source code
*/
function GetTodaysURL()
{
// Put relative or full URL's in the strings below
// First line is returned on Mondays, second on Tuesdays ...
// ... and the seventh on Sundays
var locationlist = new URLList
(
"groucho.html", // Monday
"harpo.html", // Tuesday
"zeppo.html",
"chico.html",
"harpo.html",
"groucho.html",
"chico.html" // Sunday
);
now = new Date();
num = now.getDay();
if (num == 0)
num = 7;
return locationlist.list[num-1];
}
function URLList ()
{
var argv = URLList.arguments;
var argc = argv.length;
this.list = new Object();
for (var i = 0; i < argc; i++)
this.list[i] = argv[i];
this.count = argc;
return this;
}
// -- End of JavaScript code -------------- -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=FFFFFF TEXT=000000>
<H1>JavaScript Today's Link</H1>
<B>This page contains a JavaScript that selects a different URL for each day of the
week</B>
<P>
Please note that JavaScript is currently only available in Netscape Navigator 2.0 or higher.<BR>
<FONT COLOR="931B15">Do not assume that all in your audience are using a JavaScript enabled browser.</FONT>
<HR>
<P>
This JavaScript lets you present a different link to a different document URL for each day of the week.
<P>
You can use this to direct your readers to a different site each day of the week, or if you run a daily newsletter you can use it to let readers to go to a specific file depending on the day of the week.
<P>
The script is named <B>GetTodaysURL</B> and it is placed in the HEAD section of the HTML document. The script is executed by clicking on a link containing a call to GetTodaysURL(). Also note the <FONT COLOR="FF3366">custom text</FONT> in Netscape's status area.
<P>
Example of this script picking
<A HREF=""
onClick="this.href=GetTodaysURL()"
onMouseOver="window.status='This link takes you the page of the day!'; return true">todays</A> page. Another page will be displayed tomorrow.
<P>
<P>
<B><FONT COLOR="DD0000">Internet Explorer Warning!</FONT></B><BR>
Internet Explorer support for JavaScript (called JScript, for obvious reasons ;-) is not as complete as Netscape's implementation, so the script above will give an error message in version 3.0 of MS Internet Explorer for Windows. The 3.0 beta 1 version of Internet Explorer for MacOS doesn't seem to support JScript at all.
<P>
View an example of a dynamic script that works around this bug in the <A HREF="Random Link Example">Random Link Example</A>.
<P>
<B>How to use:</B><BR>
Replace the filenames inside the script with your own URLs and edit this page contents inside the <BODY> section. (You can also copy the entire script to one of your existing pages).
<XMP>function GetTodaysURL()
{
// Put relative or full URL's in the strings below
// First line is returned on Mondays, second on Tuesdays ...
// ... and the seventh on Sundays
var locationlist = new URLList
(
"groucho.html", // Monday
"harpo.html", // Tuesday
"zeppo.html",
"chico.html",
"harpo.html",
"groucho.html",
"chico.html" // Sunday
);
</XMP>
<P>
Use code similar to this to let the user execute the script: